-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(async-jobs): async execution with job queue backends #3134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR implements a robust async job queue system with three backend options (Trigger.dev, Redis, Database) using an automatic fallback chain. The implementation follows a clean adapter pattern with a unified Key Changes:
Architecture: Database Changes: Confidence Score: 4.5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant API as API Route<br/>/api/workflows/[id]/execute
participant Config as Job Queue Config
participant Backend as Job Backend<br/>(Redis/DB/Trigger.dev)
participant Worker as Background Worker<br/>(executeWorkflowJob)
participant Executor as Workflow Executor
Client->>API: POST with X-Execution-Mode: async
API->>Config: getJobQueue()
Config->>Config: Determine backend type<br/>(trigger.dev → redis → database)
Config-->>API: Return backend instance
API->>Backend: enqueue('workflow-execution', payload)
Backend->>Backend: Generate jobId (run_xxxx)
Backend->>Backend: Store job with status=pending
alt Redis Backend
Backend->>Backend: Set TTL=48h (max lifetime)
end
Backend-->>API: Return jobId
API->>Client: 202 Accepted<br/>{jobId, statusUrl, async: true}
alt shouldExecuteInline() == true (Redis/DB)
API->>Worker: Fire-and-forget execution
Worker->>Backend: startJob(jobId)
Backend->>Backend: Set status=processing<br/>Increment attempts
Worker->>Executor: executeWorkflowCore()
Executor-->>Worker: Execution result
alt Success
Worker->>Backend: completeJob(jobId, output)
Backend->>Backend: Set status=completed<br/>Store output
alt Redis Backend
Backend->>Backend: Set TTL=24h (retention)
end
else Failure
Worker->>Backend: markJobFailed(jobId, error)
Backend->>Backend: Set status=failed<br/>Store error
alt Redis Backend
Backend->>Backend: Set TTL=24h (retention)
end
end
else Trigger.dev Backend
Note over Backend: Trigger.dev handles execution<br/>via its own worker system
end
Client->>API: GET /api/jobs/{jobId}
API->>Backend: getJob(jobId)
Backend-->>API: Job with status & output
API-->>Client: Job status response
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 files reviewed, 1 comment
|
@cursor review |
|
@greptile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, 1 comment
Resolve conflict in env.ts - keep staging's sync timeout values (3000) while adding async timeout variants (5400) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@cursor review |
|
@greptile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8 files reviewed, no comments
|
@cursor review |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Summary
createMockRedis()to@sim/testingType of Change
Testing
Checklist
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Cursor Bugbot found 2 potential issues for commit fe401f2